-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: refactor mock api server to fail on error #141
Conversation
af9b6ef
to
1c85de4
Compare
562f56e
to
f40e6e5
Compare
@@ -17,4 +17,4 @@ DB_PASS=change-this-sqlpassword | |||
WIKIBASE_PINGBACK=false | |||
# wikibase.svc is the internal docker hostname, change this value to the public hostname | |||
WIKIBASE_HOST=wikibase.svc | |||
WIKIBASE_PORT=80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this has some background, but I cannot bind to port 80 locally using docker compose unless I elevate priviliges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no reason to keep this like it is; I guess it was just picked at some point to look closest to prod. After all these port names end up in the URIs of the triples that go in the queryservice
@@ -1,18 +1,5 @@ | |||
version: '2' | |||
services: | |||
|
|||
wikibase: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know what these overrides are good for. Containers can use the Docker network (instead of the host one) in both CI and local testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no clue either.. let's not keep it
@@ -1,41 +1,52 @@ | |||
var http = require('http'); | |||
const wbEdit = require( 'wikibase-edit' )( require( './wikibase-edit.config' ) ); | |||
|
|||
var x = 0 | |||
http.createServer(async function (req, res) { | |||
res.writeHead(200, {'Content-Type': 'text/json'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this as the first line meant we'd 200 even when wikibase was still down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
res.end(JSON.stringify([responseObject])); | ||
return; | ||
default: | ||
res.writeHead(404); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this; good idea to ensure it 404s everywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I understand how this resolve the race between wikibase and the fake api. I'm not quite sure I understand how our test "passes by accident" before this though; perhaps if I don't get my head around it tomorrow you can explain.
"passes by accident" was badly phrased when I did not understand every detail of this yet. What happens is that the previous tests relied on an intricate choreography of retries and server restarts that stopped working when more requests were made against the failing server. |
Connects #139
The mock api service relies on the
wikibase
service being up. Currently they are racing, and the mock api keeps crashing because of an unhandled promise rejection untilwikibase
is up.When adding additional logic in #139, this fail-forward approach does not work anymore as the seeding fails to win the race against the retry logic.
This PR does two things: